//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Resource Application Block
//===============================================================================

using System;
using System.Collections;
#if !NUNIT
using Microsoft.VisualStudio.TestTools.UnitTesting;
#else
using NUnit.Framework;
using TestClass = NUnit.Framework.TestFixtureAttribute;
using TestInitialize = NUnit.Framework.SetUpAttribute;
using TestCleanup = NUnit.Framework.TearDownAttribute;
using TestMethod = NUnit.Framework.TestAttribute;
#endif

namespace EntLibContrib.Resource.Providers.Tests
{
	[TestClass]
	public class BinaryResourceProviderFixture
	{
		private static string resourcePathName = @".\";
		private static string noResourcePathName = @"..\";
		private static string resourceBaseName = "Resources";

		[TestMethod]
		public void CanInitializeResourceProviderFromConfigurationObjects()
    {
			BinaryResourceProvider binaryResourceProvider = new BinaryResourceProvider(resourcePathName, resourceBaseName);
			System.Resources.ResourceManager resourceManager = binaryResourceProvider.CreateResourceManager();

			Assert.IsNotNull(resourceManager, "The resource manager should now exist");
			Assert.AreEqual("e-World Developments Ltd", resourceManager.GetString("Ewdev"), "We should now be able to read resources");
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void NullPathNameThrowsException ()
		{
			BinaryResourceProvider binaryResourceProvider = new BinaryResourceProvider(null, resourceBaseName);
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void InvalidPathNameThrowsException ()
		{
			BinaryResourceProvider binaryResourceProvider = new BinaryResourceProvider("invalidPathName", resourceBaseName);
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void PathNameWithNoResourcesThrowsException ()
		{
			BinaryResourceProvider binaryResourceProvider = new BinaryResourceProvider(noResourcePathName, resourceBaseName);
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void NullBaseNameThrowsException ()
		{
			BinaryResourceProvider binaryResourceProvider = new BinaryResourceProvider(resourcePathName, null);
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentException))]
		public void InvalidBaseNameThrowsException ()
		{
			BinaryResourceProvider binaryResourceProvider = new BinaryResourceProvider(resourcePathName, "invalidBaseName");
		}
	}
}